
package com.pengshun.modules.api.coal.controller;

import com.pengshun.modules.api.coal.service.ProblemService;
import com.pengshun.modules.api.coal.service.dto.ProblemDto;
import com.pengshun.modules.api.coal.validator.First;
import com.pengshun.modules.api.coal.validator.Second;
import com.pengshun.modules.common.BaseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import springfox.documentation.annotations.ApiIgnore;


/**
* @author lifei
* @date 2020-11-13
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "常见问题管理")
@RequestMapping("/api/problem")
@ApiIgnore
public class ProblemController {

    private final ProblemService problemService;

    @ApiOperation(value = "查询问题分类")
    @GetMapping(value = "/type")
    public BaseResult selectAllProblemType() throws Exception {
        BaseResult res = problemService.selectAllProblemType();
        return res;
    }

    @ApiOperation(value = "根据类型id查询" ,notes = "类型id不传查询全部，0代表常见")
    @GetMapping(value = "/list")
    @ApiImplicitParam(name = "problemTypeId", value = "类型id", dataType = "string",   paramType = "query")
    public BaseResult findByProblemTypeId(@ApiIgnore @Validated(value = {Second.class})ProblemDto dto) throws Exception {
        BaseResult res = problemService.findByProblemTypeId(dto.getProblemTypeId());
        return res;
    }
    @ApiOperation(value = "根据id查询详情" ,notes = "类型id不传查询全部，0代表常见")
    @GetMapping(value = "/detil")
    @ApiImplicitParam(name = "id", value = "类型id", dataType = "string",   paramType = "query")
    public BaseResult findByProblemDetil(@ApiIgnore @Validated(value = {First.class})ProblemDto dto) throws Exception {
        BaseResult res = problemService.findByProblemDetil(dto.getId());
        return res;
    }

}